package com.asset.dispoal.verdict;

import com.asset.dispoal.verdict.api.JudgmentBookService;
import com.asset.dispoal.verdict.dto.request.CreateOrEditItemRequest;
import com.asset.dispoal.verdict.dto.request.JudgmentItemRequest;
import com.asset.dispoal.verdict.dto.response.JudgmentItemResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.mhuang.pacebox.springboot.core.permission.annotation.Permission;
import tech.mhuang.pacebox.springboot.protocol.Result;
import tech.mhuang.pacebox.springboot.protocol.data.PageVO;

/**
 * @description:
 * @author: yf
 * @date: 2022-09-06
 */
@RestController
@Api(value = "判决书分类管理", tags = "判决书分类管理")
@RequestMapping("gb/verdictItem")
public class VerdictItemController {
    @Autowired
    private JudgmentBookService judgmentBookService;

    @Permission(code = "verdictItem:query")
    @ApiOperation(value = "判决书提取项目列表通用查询（分页）")
    @PostMapping("/queryItemByBookId")
    public Result<PageVO<JudgmentItemResponse>> queryItemByBookId(@RequestBody JudgmentItemRequest request) {
        return judgmentBookService.queryJudgmentById(request);
    }

    @Permission(code = "verdictItem:query")
    @ApiOperation(value = "根据提取项目id获取回显详情")
    @GetMapping("/echoItemById")
    public Result<JudgmentItemResponse> queryItemById(String itemId) {
        return judgmentBookService.queryItemById(itemId);
    }

    @Deprecated
    @ApiOperation(value = "新增/修改信息")
    @PostMapping("/insertOrUpdate")
    public Result insertOrUpdate(@RequestBody CreateOrEditItemRequest request) {
        return judgmentBookService.createOrEditBookItem(request);
    }

    @Permission(code = "verdictItem:add")
    @ApiOperation(value = "新增")
    @PostMapping("/insert")
    public Result insert(@RequestBody CreateOrEditItemRequest request) {
        return judgmentBookService.createOrEditBookItem(request);
    }

    @Permission(code = "verdictItem:update")
    @ApiOperation(value = "修改信息")
    @PostMapping("/update")
    public Result update(@RequestBody CreateOrEditItemRequest request) {
        return judgmentBookService.createOrEditBookItem(request);
    }

    @Permission(code = "verdictItem:del")
    @ApiOperation(value = "删除")
    @GetMapping("/delete")
    public Result delete(String itemId) {
        return judgmentBookService.deleteItemById(itemId);
    }
}
